<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_class</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="System Catalogs"
HREF="catalogs.html"><LINK
REL="PREVIOUS"
TITLE="pg_cast"
HREF="catalog-pg-cast.html"><LINK
REL="NEXT"
TITLE="pg_constraint"
HREF="catalog-pg-constraint.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-12-01T22:07:59"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1.2 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="pg_cast"
HREF="catalog-pg-cast.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 45. System Catalogs</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="pg_constraint"
HREF="catalog-pg-constraint.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CATALOG-PG-CLASS"
>45.11. <TT
CLASS="STRUCTNAME"
>pg_class</TT
></A
></H1
><P
>   The catalog <TT
CLASS="STRUCTNAME"
>pg_class</TT
> catalogs tables and most
   everything else that has columns or is otherwise similar to a
   table.  This includes indexes (but see also
   <TT
CLASS="STRUCTNAME"
>pg_index</TT
>), sequences, views, composite types,
   and TOAST tables; see <TT
CLASS="STRUCTFIELD"
>relkind</TT
>.
   Below, when we mean all of these
   kinds of objects we speak of <SPAN
CLASS="QUOTE"
>"relations"</SPAN
>.  Not all
   columns are meaningful for all relation types.
  </P
><DIV
CLASS="TABLE"
><A
NAME="AEN85471"
></A
><P
><B
>Table 45-11. <TT
CLASS="STRUCTNAME"
>pg_class</TT
> Columns</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Type</TH
><TH
>References</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relname</TT
></TD
><TD
><TT
CLASS="TYPE"
>name</TT
></TD
><TD
>&nbsp;</TD
><TD
>Name of the table, index, view, etc.</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relnamespace</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-namespace.html"
><TT
CLASS="STRUCTNAME"
>pg_namespace</TT
></A
>.oid</TT
></TD
><TD
>       The OID of the namespace that contains this relation
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reltype</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-type.html"
><TT
CLASS="STRUCTNAME"
>pg_type</TT
></A
>.oid</TT
></TD
><TD
>       The OID of the data type that corresponds to this table's row type,
       if any (zero for indexes, which have no <TT
CLASS="STRUCTNAME"
>pg_type</TT
> entry)
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reloftype</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-type.html"
><TT
CLASS="STRUCTNAME"
>pg_type</TT
></A
>.oid</TT
></TD
><TD
>       For typed tables, the OID of the underlying composite type,
       zero for all other relations
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relowner</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-authid.html"
><TT
CLASS="STRUCTNAME"
>pg_authid</TT
></A
>.oid</TT
></TD
><TD
>Owner of the relation</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relam</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-am.html"
><TT
CLASS="STRUCTNAME"
>pg_am</TT
></A
>.oid</TT
></TD
><TD
>If this is an index, the access method used (B-tree, hash, etc.)</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relfilenode</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
>&nbsp;</TD
><TD
>Name of the on-disk file of this relation; zero means this
       is a <SPAN
CLASS="QUOTE"
>"mapped"</SPAN
> relation whose disk file name is determined
       by low-level state</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reltablespace</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-tablespace.html"
><TT
CLASS="STRUCTNAME"
>pg_tablespace</TT
></A
>.oid</TT
></TD
><TD
>       The tablespace in which this relation is stored.  If zero,
       the database's default tablespace is implied.  (Not meaningful
       if the relation has no on-disk file.)
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relpages</TT
></TD
><TD
><TT
CLASS="TYPE"
>int4</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Size of the on-disk representation of this table in pages (of size
       <TT
CLASS="SYMBOL"
>BLCKSZ</TT
>).  This is only an estimate used by the
       planner.  It is updated by <TT
CLASS="COMMAND"
>VACUUM</TT
>,
       <TT
CLASS="COMMAND"
>ANALYZE</TT
>, and a few DDL commands such as
       <TT
CLASS="COMMAND"
>CREATE INDEX</TT
>.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reltuples</TT
></TD
><TD
><TT
CLASS="TYPE"
>float4</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Number of rows in the table.  This is only an estimate used by the
       planner.  It is updated by <TT
CLASS="COMMAND"
>VACUUM</TT
>,
       <TT
CLASS="COMMAND"
>ANALYZE</TT
>, and a few DDL commands such as
       <TT
CLASS="COMMAND"
>CREATE INDEX</TT
>.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reltoastrelid</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-class.html"
><TT
CLASS="STRUCTNAME"
>pg_class</TT
></A
>.oid</TT
></TD
><TD
>       OID of the TOAST table associated with this table, 0 if none.  The
       TOAST table stores large attributes <SPAN
CLASS="QUOTE"
>"out of line"</SPAN
> in a
       secondary table.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reltoastidxid</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-class.html"
><TT
CLASS="STRUCTNAME"
>pg_class</TT
></A
>.oid</TT
></TD
><TD
>       For a TOAST table, the OID of its index.  0 if not a TOAST table.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relhasindex</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>       True if this is a table and it has (or recently had) any indexes
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relisshared</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>       True if this table is shared across all databases in the cluster.  Only
       certain system catalogs (such as <TT
CLASS="STRUCTNAME"
>pg_database</TT
>)
       are shared.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relpersistence</TT
></TD
><TD
><TT
CLASS="TYPE"
>char</TT
></TD
><TD
>&nbsp;</TD
><TD
>       <TT
CLASS="LITERAL"
>p</TT
> = permanent table, <TT
CLASS="LITERAL"
>u</TT
> = unlogged table,
       <TT
CLASS="LITERAL"
>t</TT
> = temporary table
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relkind</TT
></TD
><TD
><TT
CLASS="TYPE"
>char</TT
></TD
><TD
>&nbsp;</TD
><TD
>       <TT
CLASS="LITERAL"
>r</TT
> = ordinary table, <TT
CLASS="LITERAL"
>i</TT
> = index,
       <TT
CLASS="LITERAL"
>S</TT
> = sequence, <TT
CLASS="LITERAL"
>v</TT
> = view, <TT
CLASS="LITERAL"
>c</TT
> =
       composite type, <TT
CLASS="LITERAL"
>t</TT
> = TOAST table,
       <TT
CLASS="LITERAL"
>f</TT
> = foreign table
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relnatts</TT
></TD
><TD
><TT
CLASS="TYPE"
>int2</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Number of user columns in the relation (system columns not
       counted).  There must be this many corresponding entries in
       <TT
CLASS="STRUCTNAME"
>pg_attribute</TT
>.  See also
       <TT
CLASS="LITERAL"
>pg_attribute.attnum</TT
>.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relchecks</TT
></TD
><TD
><TT
CLASS="TYPE"
>int2</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Number of <TT
CLASS="LITERAL"
>CHECK</TT
> constraints on the table; see
       <A
HREF="catalog-pg-constraint.html"
><TT
CLASS="STRUCTNAME"
>pg_constraint</TT
></A
> catalog
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relhasoids</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>       True if we generate an OID for each row of the relation
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relhaspkey</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>       True if the table has (or once had) a primary key
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relhasrules</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>       True if table has (or once had) rules; see
       <A
HREF="catalog-pg-rewrite.html"
><TT
CLASS="STRUCTNAME"
>pg_rewrite</TT
></A
> catalog
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relhastriggers</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>       True if table has (or once had) triggers; see
       <A
HREF="catalog-pg-trigger.html"
><TT
CLASS="STRUCTNAME"
>pg_trigger</TT
></A
> catalog
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relhassubclass</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>True if table has (or once had) any inheritance children</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relfrozenxid</TT
></TD
><TD
><TT
CLASS="TYPE"
>xid</TT
></TD
><TD
>&nbsp;</TD
><TD
>       All transaction IDs before this one have been replaced with a permanent
       (<SPAN
CLASS="QUOTE"
>"frozen"</SPAN
>) transaction ID in this table.  This is used to track
       whether the table needs to be vacuumed in order to prevent transaction
       ID wraparound or to allow <TT
CLASS="LITERAL"
>pg_clog</TT
> to be shrunk.  Zero
       (<TT
CLASS="SYMBOL"
>InvalidTransactionId</TT
>) if the relation is not a table.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relacl</TT
></TD
><TD
><TT
CLASS="TYPE"
>aclitem[]</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Access privileges; see
       <A
HREF="sql-grant.html"
>GRANT</A
> and
       <A
HREF="sql-revoke.html"
>REVOKE</A
>
       for details
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>reloptions</TT
></TD
><TD
><TT
CLASS="TYPE"
>text[]</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Access-method-specific options, as <SPAN
CLASS="QUOTE"
>"keyword=value"</SPAN
> strings
      </TD
></TR
></TBODY
></TABLE
></DIV
><P
>   Several of the Boolean flags in <TT
CLASS="STRUCTNAME"
>pg_class</TT
> are maintained
   lazily: they are guaranteed to be true if that's the correct state, but
   may not be reset to false immediately when the condition is no longer
   true.  For example, <TT
CLASS="STRUCTFIELD"
>relhasindex</TT
> is set by
   <TT
CLASS="COMMAND"
>CREATE INDEX</TT
>, but it is never cleared by
   <TT
CLASS="COMMAND"
>DROP INDEX</TT
>.  Instead, <TT
CLASS="COMMAND"
>VACUUM</TT
> clears
   <TT
CLASS="STRUCTFIELD"
>relhasindex</TT
> if it finds the table has no indexes.  This
   arrangement avoids race conditions and improves concurrency.
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="catalog-pg-cast.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="catalog-pg-constraint.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_cast</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_constraint</TT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>